<?php
/**
 * @Author: Administrator
 * @Date:   2014-08-06 22:39:11
 * @Last Modified by:   Administrator
 * @Last Modified time: 2014-08-06 23:48:36
 */

/**
 * 多维数组去重复
 * @param  [type]  $array2D  [description]
 * @param  boolean $stkeep   [description]
 * @param  boolean $ndformat [description]
 * @return [type]            [description]
 */
function unique_arr($array2D,$split=',',$stkeep=false,$ndformat=true)
{
    // 判断是否保留一级数组键 (一级数组键可以为非数字)
    if($stkeep) $stArr = array_keys($array2D);
    // 判断是否保留二级数组键 (所有二级数组键必须相同)
    if($ndformat) $ndArr = array_keys(end($array2D));
    //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
    foreach ($array2D as $v){
        $v = join($split,$v); //用$split组合防止与数组元素中有相同
        $temp[] = $v;
    }
    //去掉重复的字符串,也就是重复的一维数组
    $temp = array_unique($temp);
    $output=array();
    //再将拆开的数组重新组装
    foreach ($temp as $k => $v)
    {
        if($stkeep) $k = $stArr[$k];
        if($ndformat)
        {
            $tempArr = explode($split,$v); 
            foreach($tempArr as $ndkey => $ndval) $output[$k][$ndArr[$ndkey]] = $ndval;
        }
        else $output[$k] = explode(",",$v); 
    }
    return $output;
}



function judgeEqual($key1,$key2){
    if(array_diff($key1,$key2) || array_diff($key2,$key1)){
        return true;
    }else{
        return false;
    }
    
}